home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 351-375 / disk_362 / rubik / source / getwindow.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  5KB  |  210 lines

  1. /************************************************************
  2. *
  3. * getwindow.c ......used in rubik.c
  4. *
  5. * M.J.R.  19/12/89
  6. *
  7. *************************************************************/
  8.  
  9. struct IntuitionBase *IntuitionBase = NULL;
  10. struct GfxBase *GfxBase = NULL;
  11. struct IntuiMessage *MyIntuiMessage = NULL;
  12.  
  13. extern struct Screen *scr1, *scr2;
  14. extern struct Gadget divegadget;
  15. extern struct TextAttr ta;
  16.  
  17. struct NewScreen ns =
  18.     {
  19.     0,              /* left edge - should be zero */
  20.     0,              /* top edge */
  21.     320,            /* width - low resolution */
  22.     200,            /* height - non-interlace */
  23.     3,              /* depth - 8 colours will be available */
  24.     0,7,            /* detail pen and block pen specifications */
  25.     NULL,              /* display mode */
  26.     CUSTOMSCREEN,    /* the screen type */
  27.     &ta,            /* font */
  28.     NULL,            /* no default title */
  29.     NULL,            /* no special screen gadgets */
  30.     NULL,            /* no special custom bitmap */
  31.     };
  32.  
  33. extern struct Window *wnd1, *wnd2;
  34.  
  35. struct NewWindow nw =
  36.     {
  37.     0,0,320,199,            /* position and size    */
  38.     0,7,                    /* pens                    */
  39.     CLOSEWINDOW |
  40.     GADGETUP |
  41.     MOUSEBUTTONS,            /* IDCMPFlags            */
  42.     WINDOWCLOSE |
  43.     BORDERLESS |
  44.     ACTIVATE |
  45.     RMBTRAP,                /* flags                */
  46.     &divegadget,            /* gadgets                */
  47.     NULL,                    /* no special checkmark */
  48.     NULL,                    /* no title!            */
  49.     NULL,                    /* screen pointer        */
  50.     NULL,                    /* no bitmap            */
  51.     0,0,                    /* minimum sizes        */
  52.     320,199,                /* maximum sizes        */
  53.     CUSTOMSCREEN            /* type of screen        */
  54.     };
  55.  
  56. WORD areabuffer[25];        /*  room for up to a decagon    */
  57.  
  58. struct TmpRas tmpras;
  59. struct AreaInfo ai;
  60.  
  61. void MyCleanup()
  62.     {  
  63.     if (wnd2)
  64.         CloseWindow(wnd2);
  65.     if (wnd1)
  66.         CloseWindow(wnd1);
  67.     if (scr2)
  68.         CloseScreen(scr2);
  69.     if (scr1)
  70.         CloseScreen(scr1);
  71.     if (GfxBase != NULL)
  72.         CloseLibrary((struct Library *) GfxBase);
  73.     if (IntuitionBase != NULL)
  74.         CloseLibrary((struct Library *) IntuitionBase);
  75.     }
  76.  
  77. void cleanup()
  78.     {
  79.     FreeRaster(tmpras.RasPtr,320,199);
  80.     MyCleanup();
  81.     }
  82.  
  83. void getwindow()
  84.     {
  85.     IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",0);
  86.     if (IntuitionBase == NULL)
  87.         {
  88.         MyCleanup();
  89.         exit(FALSE);
  90.         }
  91.  
  92.     GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0);
  93.     if (GfxBase == NULL)
  94.         {
  95.         MyCleanup();
  96.         exit(FALSE);
  97.         }    
  98.  
  99.     scr1 = (struct Screen *)OpenScreen(&ns);
  100.     if (scr1 == NULL)
  101.         {
  102.         MyCleanup();
  103.         exit(FALSE);
  104.         }
  105.  
  106.     scr2 = (struct Screen *)OpenScreen(&ns);
  107.     if (scr1 == NULL)
  108.         {
  109.         MyCleanup();
  110.         exit(FALSE);
  111.         }
  112.  
  113.     SetRGB4(&(scr1->ViewPort),1,14,12,2);        /*    y    */
  114.     SetRGB4(&(scr1->ViewPort),2,13,13,13);        /*    w    */
  115.     SetRGB4(&(scr1->ViewPort),3,0,10,0);        /*    g    */
  116.     SetRGB4(&(scr1->ViewPort),4,2,4,11);        /*    bu    */
  117.     SetRGB4(&(scr1->ViewPort),5,15,5,0);        /*    o    */
  118.     SetRGB4(&(scr1->ViewPort),6,11,3,1);        /*    bn    */
  119.     SetRGB4(&(scr1->ViewPort),7,10,10,10);        /*    gy    */
  120.     SetRGB4(&(scr1->ViewPort),0,0,0,0);            /*    bk    */
  121.  
  122.     SetRGB4(&(scr2->ViewPort),1,14,12,2);        /*    y    */
  123.     SetRGB4(&(scr2->ViewPort),2,13,13,13);        /*    w    */
  124.     SetRGB4(&(scr2->ViewPort),3,0,10,0);        /*    g    */
  125.     SetRGB4(&(scr2->ViewPort),4,2,4,11);        /*    bu    */
  126.     SetRGB4(&(scr2->ViewPort),5,15,5,0);        /*    o    */
  127.     SetRGB4(&(scr2->ViewPort),6,11,3,1);        /*    bn    */
  128.     SetRGB4(&(scr2->ViewPort),7,10,10,10);        /*    gy    */
  129.     SetRGB4(&(scr2->ViewPort),0,0,0,0);            /*    bk    */
  130.  
  131.     nw.Screen = scr1; /* fix the pointer into the struct  */
  132.  
  133.     wnd1 = (struct Window *)OpenWindow(&nw);
  134.     if (wnd1 == NULL)
  135.         {
  136.         MyCleanup();
  137.         exit(FALSE);
  138.         }
  139.  
  140.     nw.Screen = scr2; /* fix the pointer into the struct  */
  141.  
  142.     wnd2 = (struct Window *)OpenWindow(&nw);
  143.     if (wnd2 == NULL)
  144.         {
  145.         MyCleanup();
  146.         exit(FALSE);
  147.         }
  148.  
  149.     InitArea(&ai,&(areabuffer[0]),10);
  150.  
  151.     wnd1->RPort->AreaInfo = &ai;
  152.     wnd1->RPort->TmpRas = InitTmpRas
  153.                                     (
  154.                                     &tmpras,
  155.                                     AllocRaster(320,199),
  156.                                     RASSIZE(320,199)
  157.                                     );
  158.     wnd2->RPort->AreaInfo = &ai;
  159.     wnd2->RPort->TmpRas = wnd1->RPort->TmpRas;
  160.     
  161.     SetAPen(wnd2->RPort,7);
  162.     SetDrMd(wnd2->RPort,JAM1);
  163.     Move(wnd2->RPort,197,31);
  164.     Draw(wnd2->RPort,197,23);
  165.     Draw(wnd2->RPort,237,23);
  166.     Move(wnd2->RPort,276,31);
  167.     Draw(wnd2->RPort,276,23);
  168.     Draw(wnd2->RPort,308,23);
  169.     Move(wnd2->RPort,199,90);
  170.     Draw(wnd2->RPort,199,82);
  171.     Draw(wnd2->RPort,248,82);
  172.     Draw(wnd2->RPort,248,90);
  173.     Move(wnd2->RPort,260,90);
  174.     Draw(wnd2->RPort,260,82);
  175.     Draw(wnd2->RPort,309,82);
  176.     Draw(wnd2->RPort,309,90);
  177.     Move(wnd2->RPort,270,115);
  178.     Draw(wnd2->RPort,301,115);
  179.     Move(wnd2->RPort,265,147);
  180.     Draw(wnd2->RPort,265,139);
  181.     Draw(wnd2->RPort,305,139);
  182.     
  183.     RectFill(wnd2->RPort,206,101,244,112);
  184.     Move(wnd2->RPort,253,137);
  185.     Draw(wnd2->RPort,253,149);
  186.     Draw(wnd2->RPort,197,149);
  187.     Draw(wnd2->RPort,197,137);
  188.     Draw(wnd2->RPort,253,137);
  189.     Draw(wnd2->RPort,253,125);
  190.     Draw(wnd2->RPort,197,125);
  191.     Draw(wnd2->RPort,197,137);
  192.     Draw(wnd2->RPort,197,113);
  193.     Draw(wnd2->RPort,253,113);
  194.     Draw(wnd2->RPort,253,125);
  195.     
  196.     Move(wnd2->RPort,210,110);
  197.     SetAPen(wnd2->RPort,0);
  198.     Text(wnd2->RPort,"MODE",4);
  199.     
  200.     ClipBlit
  201.         (
  202.         wnd2->RPort,190,20,
  203.         wnd1->RPort,190,20,
  204.         128,177,
  205.         0xc0
  206.         );
  207.     }
  208.  
  209.